
$('.tou').load('head.html')
$('.wei').load('footer.html')
var str = localStorage.getItem("data1");
var obj = JSON.parse(str);
var html = ``
var mun = 0
$.each(obj, function (index, { img, name, price, count }) {

    html += `<tr>
                <td><div class="img"><div>
                            <a href="./detail.shtml?id=8349" target="_blank">
                                <img  style=" width: 180px" src="${img}">
                            </a>
                        </div>
                    </div>
                </td>
                <td class="td-1"><span><a href="./detail.shtml?id=8349" target="_blank">${name}</a></span>
                </td>
                <td class="td-2"></td>
                <td><span>${price}.00 元</span></td>
                <td><span>${count}</span></td>
                <td><b>${price * count}.00 元</b></td>
            </tr>`
    mun += price * count
})
$("tbody").html(html)
var html1 = ``

function miss() {
    html1 = `<li class="on" addressid="1715957">
                <span>${$(".wth400").val()}</span>
                <p>233</p>
                <p class="fl mr30">${$(".wth140").val()}</p>
                <a href="javascript:;" title="默认地址" class="m-r js_pay_address_default" style="background: #ccc;color: #fff;display: block;">&nbsp;&nbsp;默认地址&nbsp;&nbsp;</a>
                <a href="javascript:;" class="tx js_pay_address_edit"></a>
                <a href="javascript:;" class="gb js_pay_address_del"></a>
            </li>`
    $(".dizhi").before(html1)

}


$(".t1").find("b").html(mun + ".00 元")
$(".tj").on("click", function () {
    $("#popup_pay_address").css("display", "block")

})
$(".popup-close").on("click", function () {
    $("#popup_pay_address").css("display", "none")

})
//地址删除

$("#btn_pay_address_submit").on("click", function () {
    $("#popup_pay_address").css("display", "none")
    miss()

})
$(".js_pay_address_del").on("click", function () {
    console.log(66);

    $(this).parent(".on").remove()
})

        $.ajax({
            type: "get",
            url: "../js/data.json",
            success: function (data) {
                dd(data[0], pro)
                pro.onchange = function () {
                    var cc = dd1(data[0], this.value)
                    dd(data[0][cc], pro2)
                    pro2.onchange = function () {
                        var cc1 = dd1(data[0][cc], this.value)
                        dd(data[0][cc][cc1], pro3, 1)
                    }
                }
            }
        })
        function dd1(data1, id) {
            for (x in data1) {
                if (x)
                    if (x == id) return x
            }
        }
        function dd(e, e1, item = 0) {
            var html = `<option value=""> 请选区</option>`
            if (item) {
                for (x in e) {
                    html += `<option value="${x}">${e[x]}</option>`

                }
            } else {
                for (x in e) {
                    html += `<option value="${x}">${x}</option>`
 
                }
            }
            e1.innerHTML = html
        }

